package com.sskj.lib.widget;

import android.app.Activity;
import android.support.design.widget.BottomSheetDialog;
import android.view.View;
import android.view.ViewGroup;

import com.sskj.common.util.ClickUtil;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.R;

public class BottomDialog {

    public static void changeLanguge(Activity activity, OnSure onSure) {
        BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(activity);
        View inflate = activity.getLayoutInflater().inflate(R.layout.lib_dialog_item, null, false);
        ClickUtil.click(300, inflate.findViewById(R.id.tvCancel), bottomSheetDialog::dismiss);
        ClickUtil.click(300, inflate.findViewById(R.id.tvSOP), () -> {
            onSure.onSure("SOP");
            bottomSheetDialog.dismiss();
        });
        ClickUtil.click(300, inflate.findViewById(R.id.tvCNB), () -> {
            onSure.onSure("CNB");
            bottomSheetDialog.dismiss();
        });
        ClickUtil.click(300, inflate.findViewById(R.id.tvLNC), () -> {
            onSure.onSure("LAC");
            bottomSheetDialog.dismiss();
        });

        bottomSheetDialog.setContentView(inflate);
        try {
            // hack bg color of the BottomSheetDialog
            ViewGroup parent = (ViewGroup) inflate.getParent();
            parent.setBackgroundResource(android.R.color.transparent);
        } catch (Exception e) {
            e.printStackTrace();
        }
        bottomSheetDialog.setCancelable(true);
        bottomSheetDialog.setCanceledOnTouchOutside(true);
        bottomSheetDialog.show();
    }

    public static void onContact(Activity activity) {
        BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(activity);
        View inflate = activity.getLayoutInflater().inflate(R.layout.lib_contact_item, null, false);
        ClickUtil.click(300, inflate.findViewById(R.id.btCancel), bottomSheetDialog::dismiss);
        ClickUtil.click(300, inflate.findViewById(R.id.btSure), () -> {
            ToastUtil.showShort("联系客服");
            bottomSheetDialog.dismiss();
        });

        bottomSheetDialog.setContentView(inflate);
        try {
            // hack bg color of the BottomSheetDialog
            ViewGroup parent = (ViewGroup) inflate.getParent();
            parent.setBackgroundResource(android.R.color.transparent);
        } catch (Exception e) {
            e.printStackTrace();
        }
        bottomSheetDialog.setCancelable(true);
        bottomSheetDialog.setCanceledOnTouchOutside(true);
        bottomSheetDialog.show();
    }

    public interface OnSure {
        void onSure(String tv);
    }

    public interface OnSureStrs {
        void onSure(String... tv);
    }
//
//    public interface OnSureCharge {
//        void onSure(RechOrWithBean data);
//    }
//
//    public interface OnSureWallet {
//        void onSure(WalletTransferBean data);
//    }
//
//    public interface onSureTransfer {
//        void onSure(TransferInsidePreBean data);
//    }
//
//    public interface PathOnSure {
//        void onSure(WalletPathBean walletPathBean);
//
//    }
}
